package com.isoft.mapper;

import com.isoft.entity.DfmeOnreEntity;
import org.apache.ibatis.annotations.*;

@Mapper
public interface DfmeOnreMapper {

    @Insert("INSERT INTO MSG_META(SENDER, RECEIVER, SEQUENCE_NUMBER, DATE_TIME, MSG_TYPE, SUB_TYPE) VALUES(#{entity.meta.sender}, #{entity.meta.receiver}, #{entity.meta.sequenceNumber}, TO_TIMESTAMP(#{entity.meta.dateTime}, 'YYYYMMDDHH24MISS'), #{entity.meta.type}, #{entity.meta.subType})")
    void insertMeta(@Param("entity") DfmeOnreEntity entity);

    @Insert("INSERT INTO FLIGHT_BASE(" +
            "FLIGHT_ID, FLIGHT_ATTRIBUTE, FLIGHT_FILE_ID, FLIGHT_IDENTIFIER) " +
            "VALUES(" +
            "#{dflt.flightId,jdbcType=NUMERIC}, " +
            "#{dflt.flightAttribute,jdbcType=VARCHAR}, " +
            "#{dflt.flightFileId,jdbcType=VARCHAR}, " +
            "#{dflt.flightIdentifier,jdbcType=VARCHAR})")
    int insertFlightBase(DfmeOnreEntity entity);

    @Select("SELECT COUNT(1) FROM FLIGHT_BASE WHERE FLIGHT_FILE_ID = #{flightFileId}")
    int existsFlightBase(@Param("flightFileId") String flightFileId);
}